package besta.moon.engine.store;

import java.sql.*;

import besta.moon.MoonException;
import besta.moon.MoonConnection;
import besta.moon.engine.Moon;
import besta.moon.sql.datatype.MutableNumeric;
import besta.moon.MoonCode;

public class MoonNull extends Moon {

    private final long nextPagePos;

    public MoonNull() {
        this(-1);
    }

    public MoonNull(long nextPos) {
        nextPagePos = nextPos;
    }

    @Override
    public final boolean isNull(int offset) {
        return true;
    }

    @Override
    public final boolean getBoolean(int offset, int dataType) throws Exception {
        return false;
    }

    @Override
    public final byte[] getBytes(int offset, int dataType) throws Exception {
        return null;
    }

    @Override
    public final double getDouble(int offset, int dataType) throws Exception {
        return 0;
    }

    @Override
    public final float getFloat(int offset, int dataType) throws Exception {
        return 0;
    }

    @Override
    public final int getInt(int offset, int dataType) throws Exception {
        return 0;
    }

    @Override
    public final long getLong(int offset, int dataType) throws Exception {
        return 0;
    }

    @Override
    public final long getMoney(int offset, int dataType) throws Exception {
        return 0;
    }

    @Override
    public final MutableNumeric getNumeric(int offset, int dataType) throws Exception {
        return null;
    }

    @Override
    public final Object getObject(int offset, int dataType) throws Exception {
        return null;
    }

    @Override
    public final String getString(int offset, int dataType) throws Exception {
        return null;
    }

    @Override
    public final void scanObjectOffsets(int[] offsets, int[] dataTypes) {

    }

    @Override
    public final int getUsedSize() {
        return 0;
    }

    @Override
    public final long getNextPagePos() {
        return nextPagePos;
    }

    @Override
    public final void deleteRow(MoonConnection con) throws SQLException {
        if (nextPagePos >= 0) {
            throw MoonException.create(MoonCode.ROW_DELETED);
        }
        throw new Error();
    }

}
